import pluginVue from 'eslint-plugin-vue'
import vueTsEslintConfig from '@vue/eslint-config-typescript'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
import { dirname, resolve }from 'path'
import { fileURLToPath } from 'url'
import { readFileSync }from 'fs'

const __dirname = dirname(fileURLToPath(import.meta.url))
const autoImportConfig =JSON.parse(
  readFileSync(resolve( __dirname,'.eslintrc-auto-import.json'), 'utf8')
)

export default [
  {
    name: 'app/files-to-lint',
    files: ['**/*.{ts,mts,tsx,vue}'],
    languageOptions: {
      globals: {
        ...autoImportConfig.globals
      }
    }
  },
  {
    name: 'app/files-to-ignore',
    ignores: ['**/dist/**', '**/dist-ssr/**', '**/coverage/**'],
  },

  ...pluginVue.configs['flat/essential'],
  ...vueTsEslintConfig(),
  skipFormatting,
]
